﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace TicketSeller
{
    [DataContract(Name="route")]
    [Serializable]
    public class Route
    {
        public Route() { }

        public Route( Ticket ticket)
        {
            this.routeType = RouteType.DIRECT;
            this.routeTickets = new TicketsCollection( );
            routeTickets.Add( ticket);
        }

        public Route(TicketsCollection tickets)
        {
            this.routeType = RouteType.INDIRECT;
            routeTickets = tickets;
        }

        [DataMember]
        public RouteType routeType { set; get; }

        [DataMember]
        public TicketsCollection routeTickets { set; get; }
    }

    [DataContract]
    [Serializable]
    public enum RouteType
    {
        [EnumMember]
        DIRECT,
        [EnumMember]
        INDIRECT
    }

    [Serializable]
    [CollectionDataContract(Name = "fligtsRoutes", ItemName = "route")]
    public class RoutesCollection : List<Route>
    {
        public RoutesCollection() { }

        public RoutesCollection( List<Route> routes) : base( routes) { }
    }
}
